package com.it.myh;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * @Description: // 类说明，在创建类时要填写
 * @ClassName: Od_0215_03    // 类名，会自动填充
 * @Author: MYH          // 创建者
 * @Date: 2023/2/15 14:10   // 时间
 * @Version: 1.0     // 版本
 */
public class Od_0215_03 {

    public static void main(String[] args) {
        File file = new File("object.dat");
        ObjectOutputStream objectOutputStream = null;
        try {
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            objectOutputStream = new ObjectOutputStream(fileOutputStream);
            objectOutputStream.writeObject(new String("静静"));
            objectOutputStream.flush();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (objectOutputStream != null){
                try {
                    objectOutputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
